<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <ApproveHistory ref="approveHistory" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :total="total"
      grid-id="workflowWaitApproveMngGridId"
      @selection-change="handleGridSelectionChange">
      <el-table-column :show-overflow-tooltip="true" prop="taskTitle" label="任务标题">
        <template slot-scope="scope">
          <a title="查看明细" @click="toView(scope.row)">{{ scope.row.taskTitle }}</a>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="节点名" width="120px" />
      <el-table-column :show-overflow-tooltip="true" prop="createBy" label="申请人" />
      <el-table-column :show-overflow-tooltip="true" prop="origUserAccount" label="授权人" />
      <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期" width="150px" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="taskDesc" label="任务描述"/>
      <el-table-column :show-overflow-tooltip="true" label="操作" width="220px" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="viewApproveHistory(scope.row)">审批历史</el-button>
          <el-button type="primary" size="mini" @click="viewProgess(scope.row)">进度查看</el-button>
        </template>
      </el-table-column>
    </DataGridTable>
    <flowImageSet ref="flowImageSet" :sup_this="sup_this" :click_enable="false" />
    <DynamicLoadApvComp ref="dynamicLoadApvComp" :sup_this="sup_this" />
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import initData from '@/mixins/initData'
import { loadDataUrl } from '@/api/system/workflowApprove'
import eHeader from './module/header'
import ApproveHistory from './module/approveHistory'
import flowImageSet from '@/views/system/workflow/workflowDef/module/flowImageSet'
import DynamicLoadApvComp from '@/views/system/workflow/approve/module/DynamicLoadApvComp'

export default {
  components: { DynamicLoadApvComp, ApproveHistory, eHeader, flowImageSet },
  mixins: [initData],
  data() {
    return {
      sup_this: this
    }
  },
  created() {
    this.url = loadDataUrl()
  },
  mounted() {
    this.init()
  },
  methods: {
    parseTime,
    beforeInit() {
      return true
    },
    toView(row) {
      const _this = this.$refs.dynamicLoadApvComp
      _this.loadComp('apv' + row.defineDetailId, row.apvCompUrl, row.businessKey, row.taskTitle) // row.businessKey)
    },
    viewApproveHistory(row) {
      const _this = this.$refs.approveHistory
      _this.loadDataOfBefore(row)
      _this.dialog = true
    },
    viewProgess(row) {
      const _this = this.$refs.flowImageSet
      _this.flowKey = row.flowKey
      _this.processInstanceId = row.processInstanceId
      _this.initDisplayInfo(row.flowKey, row.activityId)
      _this.dialog = true
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
</style>
